//
//  BDJAllViewController.m
//  BuDeJie
//
//  Created by Guo Rui on 2017/9/30.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "BDJAllViewController.h"

@interface BDJAllViewController ()

@end

@implementation BDJAllViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    Class class = [UITableViewCell class];
    [self.tableView registerClass:class forCellReuseIdentifier:NSStringFromClass(class)];
    
//    if (@available(iOS 11, *)) {
//        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
//    }
    self.view.backgroundColor = BDJRandomColor;
    BDJFUNC
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabBarDidRepeatClick) name:BDJTabBarButtonDidRepeatClickNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(titleButtonDidRepeatClick) name:BDJTitleButtonDidRepeatClickNotification object:nil];
    
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    NSLog(@"\n************\n %@ dealloc \n************", self.class);
}

- (void)tabBarDidRepeatClick
{
    // 点击的不是精华分栏不应该响应
    if (!self.view.window) return;
    
    // 当前控制器view没有展示也不响应
    UIScrollView *superView = (UIScrollView *)self.view.superview;
    if (superView.contentOffset.x != self.view.x) return;
    
    BDJFUNC
}

- (void)titleButtonDidRepeatClick
{
    [self tabBarDidRepeatClick];
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class]) forIndexPath:indexPath];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.text = [NSString stringWithFormat:@"%zd", indexPath.row];
    // Configure the cell...
    
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
